﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace Marking
{
    class Connection
    {
        private string connString;
        public SqlConnection conn;
        public SqlCommand cmd;
        public Connection()
        {
            connString = "Data Source=.;Initial Catalog=Watermarking;Integrated Security=True";
            conn = new SqlConnection(connString);
        }
        public void Connection_Click()
        {
            conn.Open();
            MessageBox.Show("数据库打开成功");
            cmd = conn.CreateCommand();
            cmd.CommandText = "select * from text";
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                int n2 = reader.GetInt32(reader.GetOrdinal("2"));
                MessageBox.Show(n2.ToString());
            }

            //conn.Close();
        }
    }
}
